package com.nine.pesys.model.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by L先森 on 2014/12/25.
 */
@Entity
@Table(name = "tb_equipmentDetail")
public class EquipmentDetail implements Serializable {
    private Long id;
    private Boolean isRair;
    private Boolean isBorrow;
    private Equipment equipment;
    private Set<EquipmentImformation> equipmentImformationSet = new HashSet<EquipmentImformation>();

    @Id
    @Column(name = "id",length = 10)
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column
    public Boolean getIsRair() {
        return isRair;
    }

    public void setIsRair(Boolean isRair) {
        this.isRair = isRair;
    }

    @Column
    public Boolean getIsBorrow() {
        return isBorrow;
    }

    public void setIsBorrow(Boolean isBorrow) {
        this.isBorrow = isBorrow;
    }

    @ManyToOne(targetEntity = Equipment.class,cascade = CascadeType.MERGE)
    @JoinColumn(name = "equipmentId")
    public Equipment getEquipment() {
        return equipment;
    }

    public void setEquipment(Equipment equipment) {
        this.equipment = equipment;
    }



    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "equipmentDetailId")
    public Set<EquipmentImformation> getEquipmentImformationSet() {
        return equipmentImformationSet;
    }

    public void setEquipmentImformationSet(Set<EquipmentImformation> equipmentImformationSet) {
        this.equipmentImformationSet = equipmentImformationSet;
    }
}
